;
(function() {
  'use strict';
  angular.module('services.usermanager.roleServer', [])
    .factory('roleManagerServer', roleManagerServer)
    .factory('roleManagerFormServer', roleManagerFormServer);

  function roleManagerServer(Restangular, roleManagerFormServer,$filter) {
    var messages = {};
    return {
      setMessage: function(value) {
        messages = value;
      },
      getMessage: function() {
        return messages;
      },
      querRoleManger: function(callback) {
      if(roleManagerFormServer.role.creTime!==''){
        roleManagerFormServer.role.creTime=$filter('date')(roleManagerFormServer.role.creTime, 'yyyy-MM-dd');
      }
        Restangular.all('sas/sysMng/role/query').post(roleManagerFormServer.role).then(callback);
      },
      deleteRole: function(param, callback) {
        Restangular.all('sas/sysMng/role/delete').post(param).then(callback);
      },
      addRole: function(param, callback) {
        Restangular.all('sas/sysMng/role/add').post(param).then(callback);
      },
      modify: function(param, callback) {
        Restangular.all('sas/sysMng/role/modify').post(param).then(callback);
      }
    }
  }

  function roleManagerFormServer() {
    return {
      role: {
        roleName: '',
        roleCode: '',
        creTime: '',
/*        parentName: ''*/
      },
    }


  }
})();